#include "PythonModule.hpp"
#include "Interface.hpp"



InterfaceImage::InterfaceImage(string name, float width_, float height_, float depth_){
	x = y = 0.0;
	m_depth = depth_;
	m_textureId = MaterialGestionner::getTexture(name);
	cout << "texture " << m_textureId << endl;
	width = width_; height = height_;
	vertexArray = new GLfloat[8];
	vertexArray[0] = 0.0;
	vertexArray[1] = 0.0;
	vertexArray[3] = 1.0;
	vertexArray[2] = 0.0;
	vertexArray[4] = 1.0;
	vertexArray[5] = 1.0;
	vertexArray[7] = 0.0;
	vertexArray[6] = 1.0;
};


void InterfaceImage::render() {
	glPushMatrix();
	glUseProgram(0);
	glTranslatef(x,y,0.0f);
	glBindTexture(GL_TEXTURE_2D,m_textureId);
	glScalef(width,height,1.0);
	glColor3f(1.0f,1.0,1.0);

	glBegin(GL_QUADS);
	for (unsigned int i = 0; i < 4; i++) {
		glTexCoord2f(vertexArray[2*i],vertexArray[2*i+1]);
		glVertex3f(vertexArray[2*i],vertexArray[2*i+1],m_depth);
	};
	glEnd();
	glPopMatrix();
};

void InterfaceImage::render(float tx, float ty) {
	glPushMatrix();
	glUseProgram(0);
	glTranslatef(tx,ty,0.0f);
	glBindTexture(GL_TEXTURE_2D,m_textureId);
	glScalef(width,height,1.0);
	glColor3f(1.0f,1.0,1.0);

	glBegin(GL_QUADS);
	for (unsigned int i = 0; i < 4; i++) {
		glTexCoord2f(vertexArray[2*i],vertexArray[2*i+1]);
		glVertex3f(vertexArray[2*i],vertexArray[2*i+1],m_depth);
	};
	glEnd();
	glPopMatrix();

}
